﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ServiceModel;
using WCFServiceWebRole1.Services;
using System.ServiceModel.Description;
using System.Diagnostics;

namespace WCFServiceWebRole1_Tests
{
   // [TestClass]
    public class UnitTest1
    {
        public static User_Rest_Host UserRestHost { get; set; }
        public static Iusers UserRest { get; set; }

     //   [ClassInitialize]
        public static void classInitialization(TestContext testcontext)
        {
            Trace.WriteLine("Starting Host");
            UserRestHost = new User_Rest_Host().StartHost();
            UserRest = UserRestHost.GetProxy();
        }

        // static UnitTest1 ()
        //{

        //    string baseAddress = "http://" + Environment.MachineName + ":8000/Service";

        //    ServiceHost host = new ServiceHost(typeof(user), new Uri(baseAddress));

        //    host.AddServiceEndpoint(typeof(Iusers), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior());

        //    host.Open();

        //    Console.WriteLine("Host opened");



        //    ChannelFactory<Iusers> factory = new ChannelFactory<Iusers>(new WebHttpBinding(), new EndpointAddress(baseAddress));

        //    factory.Endpoint.Behaviors.Add(new WebHttpBehavior());

        //    proxy = factory.CreateChannel();
        //}


        //    int x = 752;

        //    int y = 321;

        //    Console.WriteLine(proxy.Add(x, y));

        //    Console.WriteLine(proxy.Subtract(x, y));



        //    ((IClientChannel)proxy).Close();

        //    factory.Close();

        //    Console.Write("Press ENTER to close the service");

        //    Console.ReadLine();

        //    host.Close();

        //}

       // [TestMethod]
        public void TestMethod1()
        {
            Console.WriteLine(UserRest.getAllDevices("16"));
        }

      //  [ClassCleanup]
        public static void classCleanup()
        {
            Trace.WriteLine("Stopping Host");
            UserRestHost.StopHost();
        }
    }
}
